]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
messageTray: Move makeCloseButton() into Util
authorFlorian Müllner <fmuellner@gnome.org>
Mon, 18 Feb 2013 20:35:02 +0000 (21:35 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Tue, 19 Feb 2013 23:08:11 +0000 (00:08 +0100)
The function is useful for other modules as well, so move it to a
more generic place.

https://bugzilla.gnome.org/show_bug.cgi?id=694192

js/misc/util.js
js/ui/messageTray.js

index 98c231030ca85afc30e8ca3245479ffd18e2bce3..d0ea7ca3f4f44420be3eec8fe70f6940046499db 100644 (file)
@@ -1,6 +1,8 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
+const Clutter = imports.gi.Clutter;
 const GLib = imports.gi.GLib;
+const St = imports.gi.St;
 
 const Main = imports.ui.main;
 
@@ -208,3 +210,27 @@ function insertSorted(array, val, cmp) {
 
     return pos;
 }
+
+function makeCloseButton() {
+    let closeButton = new St.Button({ style_class: 'notification-close'});
+
+    // This is a bit tricky. St.Bin has its own x-align/y-align properties
+    // that compete with Clutter's properties. This should be fixed for
+    // Clutter 2.0. Since St.Bin doesn't define its own setters, the
+    // setters are a workaround to get Clutter's version.
+    closeButton.set_x_align(Clutter.ActorAlign.END);
+    closeButton.set_y_align(Clutter.ActorAlign.START);
+
+    // XXX Clutter 2.0 workaround: ClutterBinLayout needs expand
+    // to respect the alignments.
+    closeButton.set_x_expand(true);
+    closeButton.set_y_expand(true);
+
+    closeButton.connect('style-changed', function() {
+        let themeNode = closeButton.get_theme_node();
+        closeButton.translation_x = themeNode.get_length('-shell-close-overlap-x');
+        closeButton.translation_y = themeNode.get_length('-shell-close-overlap-y');
+    });
+
+    return closeButton;
+}
index dc182d89731ff147087019b0fabec24fe2497696..308b223e800fedf060c568f2642c6edc7815e626 100644 (file)
@@ -220,30 +220,6 @@ const URLHighlighter = new Lang.Class({
     }
 });
 
-function makeCloseButton() {
-    let closeButton = new St.Button({ style_class: 'notification-close'});
-
-    // This is a bit tricky. St.Bin has its own x-align/y-align properties
-    // that compete with Clutter's properties. This should be fixed for
-    // Clutter 2.0. Since St.Bin doesn't define its own setters, the
-    // setters are a workaround to get Clutter's version.
-    closeButton.set_x_align(Clutter.ActorAlign.END);
-    closeButton.set_y_align(Clutter.ActorAlign.START);
-
-    // XXX Clutter 2.0 workaround: ClutterBinLayout needs expand
-    // to respect the alignments.
-    closeButton.set_x_expand(true);
-    closeButton.set_y_expand(true);
-
-    closeButton.connect('style-changed', function() {
-        let themeNode = closeButton.get_theme_node();
-        closeButton.translation_x = themeNode.get_length('-shell-close-overlap-x');
-        closeButton.translation_y = themeNode.get_length('-shell-close-overlap-y');
-    });
-
-    return closeButton;
-}
-
 function strHasSuffix(string, suffix) {
     return string.substr(-suffix.length) == suffix;
 }
@@ -1383,7 +1359,7 @@ const SummaryItem = new Lang.Class({
         this.notificationStackView.add_actor(this.notificationStack);
         this.notificationStackWidget.add_actor(this.notificationStackView);
 
-        this.closeButton = makeCloseButton();
+        this.closeButton = Util.makeCloseButton();
         this.notificationStackWidget.add_actor(this.closeButton);
         this._stackedNotifications = [];
 
@@ -1638,7 +1614,7 @@ const MessageTray = new Lang.Class({
         this._clickedSummaryItemMouseButton = -1;
         this._clickedSummaryItemAllocationChangedId = 0;
 
-        this._closeButton = makeCloseButton();
+        this._closeButton = Util.makeCloseButton();
         this._closeButton.hide();
         this._closeButton.connect('clicked', Lang.bind(this, this._closeNotification));
         this._notificationWidget.add_actor(this._closeButton);